package com.javabasic.algorithm.leetcode;

/**
 * @Author xiongmin
 * @Description //TODO
 * @Date 2020/1/29 20:32
 * @Version 1.0
 **/
public class ImplementStrStr {
    public int strStr(String haystack, String needle) {
        if (needle == null || needle.isEmpty()) return 0;
        int len = needle.length();
        int len2 = haystack.length();
        for (int i = 0; i < len2-len; i++) {
            if (haystack.substring(i,i+len).equals(needle)) {
                return i;
            }
        }
        return -1;
//        return haystack.indexOf(needle);
    }
}
